package com.ztools.wx.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ztools.api.service.pc.PcCardService;
import com.ztools.common.config.rabbitMq.config.ExchangeConfig;
import com.ztools.common.model.pc.card.CardMaster;
import com.ztools.common.model.pc.card.CardRechargeRecord;
import com.ztools.common.util.common.PageUtil;
import com.ztools.common.util.common.enumUnit.RoutingKeyEnum;
import com.ztools.wx.service.WxCardService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: seeTools
 * @Date: 2023/6/26  18:16
 * @Version 1.0
 */
@Service
public class WxCardServiceImpl implements WxCardService {

    @Reference(version = "1.0", check = false, timeout = 3000)
    private PcCardService pcCardService;
    @Resource
    private RabbitTemplate rabbitTemplate;

    @Override
    public List<CardMaster> getCardList(Long memberId) {
        return pcCardService.getCardList(memberId);
    }

    @Override
    public CardMaster getCardInfoByNo(String cardNo) {
        return pcCardService.getCardInfoByNo(cardNo);
    }

    @Override
    public Page<CardRechargeRecord> getCardRechargeRecord(PageUtil<CardRechargeRecord> pageUtil) {
        return pcCardService.getCardRechargeRecord(pageUtil);
    }

    @Override
    public void openCard(Long memberId) {
        rabbitTemplate.convertAndSend(ExchangeConfig.TOPIC_EXCHANGE, RoutingKeyEnum.OPEN_CARD_KEY.getRoutingKey() + memberId, memberId.toString());
    }

}
